From: Florian Müllner Date: Fri, 18 May 2012 01:52:57 +0000 (+0200) Subject: main: Add a --list-modes command line option X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~6552 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=ecff2fa2b7baba8e608c0554f5662c3b3242cef2;p=gnome-shell.git main: Add a --list-modes command line option Add a command line option to list available modes, i.e. possible arguments for the --mode switch. https://bugzilla.gnome.org/show_bug.cgi?id=676156 --- diff --git a/js/ui/sessionMode.js b/js/ui/sessionMode.js index dd36873c3..ab9c61b8c 100644 --- a/js/ui/sessionMode.js +++ b/js/ui/sessionMode.js @@ -80,6 +80,12 @@ function modeExists(mode) { return modes.indexOf(mode) != -1; } +function listModes() { + let modes = Object.getOwnPropertyNames(_modes); + for (let i = 0; i < modes.length; i++) + print(modes[i]); +} + const SessionMode = new Lang.Class({ Name: 'SessionMode', diff --git a/src/Makefile.am b/src/Makefile.am index dc5137e34..802379405 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -93,7 +93,8 @@ gnome_shell_cflags = \ -DGNOME_SHELL_LIBEXECDIR=\"$(libexecdir)\" \ -DGNOME_SHELL_DATADIR=\"$(pkgdatadir)\" \ -DGNOME_SHELL_PKGLIBDIR=\"$(pkglibdir)\" \ - -DJSDIR=\"$(pkgdatadir)/js\" + -DJSDIR=\"$(pkgdatadir)/js\" \ + -DMUTTER_TYPELIB_DIR=\"$(MUTTER_TYPELIB_DIR)\" privlibdir = $(pkglibdir) privlib_LTLIBRARIES = libgnome-shell.la libgnome-shell-js.la diff --git a/src/main.c b/src/main.c index 97ad90af2..1f200392d 100644 --- a/src/main.c +++ b/src/main.c @@ -28,6 +28,8 @@ #include "shell-perf-log.h" #include "st.h" +#include + extern GType gnome_shell_plugin_get_type (void); #define SHELL_DBUS_SERVICE "org.gnome.Shell" @@ -175,6 +177,18 @@ shell_prefs_init (void) OVERRIDES_SCHEMA); } +static void +shell_introspection_init (void) +{ + + g_irepository_prepend_search_path (MUTTER_TYPELIB_DIR); + g_irepository_prepend_search_path (GNOME_SHELL_PKGLIBDIR); +#if HAVE_BLUETOOTH + g_irepository_prepend_search_path (BLUETOOTH_DIR); +#endif + +} + static void malloc_statistics_callback (ShellPerfLog *perf_log, gpointer data) @@ -240,6 +254,48 @@ default_log_handler (const char *log_domain, g_log_default_handler (log_domain, log_level, message, data); } +static void +shut_up (const char *domain, + GLogLevelFlags level, + const char *message, + gpointer user_data) +{ +} + +static gboolean +list_modes (const char *option_name, + const char *value, + gpointer data, + GError **error) +{ + ShellGlobal *global; + GjsContext *context; + const char *script; + int status; + + /* Many of our imports require global to be set, so rather than + * tayloring our imports carefully here to avoid that dependency, + * we just set it. + * ShellGlobal has some GTK+ dependencies, so initialize GTK+; we + * don't really care if it fails though (e.g. when running from a tty), + * so we mute all warnings */ + g_log_set_default_handler (shut_up, NULL); + gtk_init_check (NULL, NULL); + + _shell_global_init (NULL); + global = shell_global_get (); + context = _shell_global_get_gjs_context (global); + + shell_introspection_init (); + + script = "imports.ui.environment.init();" + "imports.ui.sessionMode.listModes();"; + if (!gjs_context_eval (context, script, -1, "
", &status, NULL)) + g_message ("Retrieving list of available modes failed."); + + exit (status); +} + static gboolean print_version (const gchar *option_name, const gchar *value, @@ -269,6 +325,12 @@ GOptionEntry gnome_shell_options[] = { N_("Use a specific mode, e.g. \"gdm\" for login screen"), "MODE" }, + { + "list-modes", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, + list_modes, + N_("List possible modes"), + NULL + }, { NULL } }; @@ -315,11 +377,7 @@ main (int argc, char **argv) shell_a11y_init (); shell_perf_log_init (); shell_prefs_init (); - - g_irepository_prepend_search_path (GNOME_SHELL_PKGLIBDIR); -#if HAVE_BLUETOOTH - g_irepository_prepend_search_path (BLUETOOTH_DIR); -#endif + shell_introspection_init (); /* Turn on telepathy-glib debugging but filter it out in * default_log_handler. This handler also exposes all the logs over D-Bus